#coding=utf-8
import SimpleHTTPServer
import SocketServer
import logging
import cgi
import subprocess


class AutoReleaseRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(self):
        logging.warning("======= GET STARTED =======")
        logging.warning(self.headers)
        self.path = '/index.html'
        SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)

    def do_POST(self):
        
        logging.info("got post!!")
        datasets = cgi.FieldStorage(fp = self.rfile,headers = self.headers,environ = {'REQUEST_METHOD': 'POST'})
        logging.info(str(datasets))
        id = datasets.getvalue('environ')
        name = datasets.getvalue('environ')
        
        msg = "name=="+str(name)+"   id=="+str(id)
        flag = 1
        results = {'status':flag,'msg':msg}
        self.send_datas(str(results))


logging.warning("\n")

if __name__ == '__main__':
    print 'Starting server, use <Ctrl-C> to stop'
    server = SocketServer.TCPServer(('0.0.0.0', 1024), AutoReleaseRequestHandler)
    server.serve_forever()